public class DemoFactory {

    public static void main(String[] args) {
        Application application = new CreateProA();
        Product productA = application.getObiect();
        productA.method();
    }
}

abstract class Application{
    abstract Product createProduct();
    Product getObiect(){
        Product Product = createProduct();
        return Product;
    }
}
class CreateProA extends Application{

    @Override
    Product createProduct() {
        return new ProductA();
    }
}
class CreateProB extends Application{

    @Override
    Product createProduct() {
        return new ProductB();
    }
}
/*-----------------------------------*/
interface Product{
    public void method();
}
class ProductA implements Product{


    @Override
    public void method() {
        System.out.println("ProductA的方法1");
    }
}
class ProductB implements Product{


    @Override
    public void method() {

    }
}
